home *** CD-ROM | disk | FTP | other *** search
/ Aminet 5 / Aminet 5 - March 1995.iso / Aminet / comm / bbs / VCF136.lha / VCF / VCF.rexx < prev   
Encoding:
OS/2 REXX Batch file  |  1994-11-22  |  3.7 KB  |  130 lines

  1. /*
  2. VirusChkULs V1.36
  3.         Program to automaticaly check uploaded files for Viruses
  4.         By Iain Black @ 2:263/154 (Fido) & iblack@dit.ie (Internet)
  5.         Modifications by Ian Willis:
  6.                                     */
  7.  
  8. option results
  9.  
  10. filesdir = "T:VCF_Files"             /* No trailing slash - Drives cannot be used */
  11. fndvirus = "S:VCF/FoundVirus"     /* Warns user of Virus by opening a Window */     
  12. novirus = "S:VCF/NoVirus"
  13. logfile = "S:VCF/VCF.log"
  14. vchckr = "Work:Utilities/misc./VirusChecker/virus_checker"
  15. unlhacmd = "lha e -M"                /* Make sure that lha is in the search path! */
  16. addlhacmd = "lha a"
  17. unzipcmd = "unzip"
  18.  
  19. i_started_vc = 0               /* variable which gets set if the script starts VC */
  20.  
  21. if exists(filesdir"/") then address command "delete "filesdir"/#?"
  22. else address command "makedir "filesdir
  23.  
  24. address command 'bbs:bin/trFL -oram:CheckFiles -cBBS:configs/ -a250 -d1 -n'
  25.  
  26. open('chkfiles','ram:CheckFiles','R')
  27. open('filecfg','bbs:configs/file.cfg','R')
  28.  
  29. ScanArea:
  30.  
  31.     do until arean='Area'
  32.         line=readln('chkfiles')
  33.         if eof('chkfiles')=1 then signal end
  34.         arean=left(line,4)
  35.     end
  36. found_area:
  37.     files=readln('chkfiles')
  38.     files=readln('chkfiles')
  39.     if length(files)=1 then signal ScanArea
  40.     filear=delword(line,1,3)
  41.     fileare=length(filear)
  42.     filearea=left(filear,fileare-1)
  43.     do until filearea=line
  44.         line=readln('filecfg')
  45.     end
  46.     path=readln('filecfg')
  47. scanfiles:
  48.     filename=word(files,1)
  49.     ext=right(filename,3)
  50.     filetype=upper(ext)
  51.     totalfile=insert(path,filename)
  52.         if ((~exists(totalfile)) | (filename="")) then signal scan_for_next_file
  53.     say ""
  54.     say "Checking "totalfile"...."
  55.     if filetype='LHA' then call lha
  56.     else if filetype='ZIP' then call zip
  57.     else address command 'copy 'totalfile' to 'filesdir
  58.  
  59.         if ~show(Ports,'Virus_Checker') then do
  60.            address command vchckr' -i -c1'
  61.            address command 'waitforport Virus_Checker'
  62.            i_started_vc = 1
  63.         end
  64.     address 'Virus_Checker'
  65.     'checkdrive\'filesdir
  66.     if VCHECK.0.0 = 0 then do      /* No virus in upload */
  67.             if open('info',logfile,'A') =0  then open('info',logfile,"W")
  68.         writeln('info','No known Virus Contained in 'totalfile)
  69.         if filetype='LHA' then call addlha
  70.         end
  71.         else do
  72.         do i =1 to VCHECK.0.0
  73.         VFILE=VCHECK.i.1
  74.         VINFO=VCHECK.i.2
  75.         end
  76.         if open('info',logfile,'A') =0  then open('info',logfile,"W")
  77.         writeln('info','')
  78.         writeln('info','****** Virus Alert!!! Delete The Virus NOW Using Virus Checker Manually!! ******')
  79.         writeln('info',VINFO' 'VFILE' in the archive ')
  80.         writeln('info',totalfile)
  81.         writeln('info','')
  82.         say 'Problem with file '||totalfile||' 'VINFO' 'VFILE
  83.         address command 'run 'fndvirus
  84.         end
  85.     address command 'delete all 'filesdir'/#?'
  86. scan_for_next_file:
  87.     files=readln('chkfiles')
  88.     if left(files,5)="Area " then do
  89.         line = files
  90.         signal found_area
  91.     end
  92.         if (left(files,21)~="Number of file areas:") then signal scanfiles
  93. end:
  94.     if (i_started_vc) then 'quit'
  95.     close('chkfiles')
  96.         address command "delete RAM:CheckFiles"
  97.     exit
  98.  
  99. lha:
  100.     address command unlhacmd totalfile filesdir'/'
  101.     if open('fileid',filesdir'/FILE_ID.DIZ','R') =1 then call file_id
  102.     return
  103.  
  104. zip:
  105.     address command 'copy 'totalfile' to 'filesdir
  106.     open('zipbit','t:unzipit',"W")
  107.     writeln('zipbit','cd 'filesdir)
  108.     writeln('zipbit',unzipcmd filesdir'/'filename)
  109.     close('zipbit')
  110.     address command 'execute t:unzipit'
  111.     address command 'delete t:unzipit'
  112.     if open('fileid',filesdir'/FILE_ID.DIZ','R') =1 then call file_id
  113.     return
  114.  
  115. file_id:
  116.     open('desc',totalfile||'.desc','A')
  117.     do until eof('fileid') =1
  118.         idline=readln('fileid')
  119.         writeln('desc',idline)
  120.         end
  121.     close('fileid')
  122.     close('desc')
  123.     if open('info',logfile,'A') =0  then open('info',logfile,"W")
  124.     writeln('info','A FILE_ID.DIZ has been added to the long desc. of 'totalfile)
  125.     return
  126.  
  127. addlha:
  128.     address command addlhacmd totalfile novirus
  129.         return
  130.